package com.linjj.seckill.util;

import org.apache.commons.codec.digest.DigestUtils;

public class MD5Util {
    public static String salt= "q7d8s5v";
    public static String md5(String str){
        return DigestUtils.md5Hex(str);
    }
    public static String passToForm(String pass){
        String str = ""+salt.charAt(6)+salt.charAt(2) + pass + salt.charAt(1)+salt.charAt(4)+salt.charAt(0);
        return md5(str);
    }
    public static String formToDb(String firstmd5,String randomSalt){
        String str = ""+randomSalt.charAt(6)+randomSalt.charAt(2) + firstmd5 + randomSalt.charAt(1)+randomSalt.charAt(4)+randomSalt.charAt(0);
        return md5(str);
    }

    public static void main(String[] args) {
        System.out.println(passToForm("123456"));
        System.out.println(formToDb(passToForm("123456"),salt));
    }

}
